﻿#ifndef DATA_BASE_H_
#define DATA_BASE_H_

#include <QtSql/QSqlDatabase>
#include <QDataStream>
#include "JZDbTable.h"
#include "JZDbCondition.h"
#include "JZDbConfigTable.h"

class JZDataBase
{
public:
    JZDataBase();
    ~JZDataBase();

    QSqlDatabase* database();
    bool open(QString path);
    void close();
    bool hasTable(const QString& tableName);
    void createTable(const JZDbTable& table);
    void removeTable(const QString& tableName); 
    
    int rowCount(const QString& tableName);
    QList<QSqlRecord> selectRow(const QString& tableName, const JZDbCondition& condition);
    bool insertRow(const QString& tableName, const QSqlRecord& data);
    bool updateRow(const QString& tableName, const QSqlRecord& data, const JZDbCondition& condition);
    bool deleteRow(const QString& tableName, const JZDbCondition& condition);

protected:    
    QSqlDatabase m_db;
};



#endif // !DATA_BASE_H_
